package cn.edu.scnu.vo;


public class SysResult {
    //表示状态码的数字
    private int status;
    //携带详细信息的字符串
    private String msg;
    //携带的各种数据
    private Object data;

    //准备一个封装数据的构造方法
    public SysResult(int status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public SysResult(ResultCode resultCode, String msg, Object data) {
        this.status = resultCode.code;
        this.msg = msg;
        this.data = data;
    }

    public SysResult() {
    }

    //有可能返回的只有status,msg,没有data
    //编写静态方法,获取具有参数数据的SysResult,失败做准备
    public static SysResult build(int status
            , String msg, Object data) {
        return new SysResult(status, msg, data);
    }//绝大部分时候不会出现失败

    public static SysResult build(ResultCode resultCode
            , String msg, Object data) {
        return new SysResult(resultCode, msg, data);
    }//绝大部分时候不会出现失败

    //编写一个返回成功数据的静态方法,status=200的 msg固定="ok"
    public static SysResult ok() {
        return new SysResult(200, "success", null);
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer code) {
        this.status = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }


}
